package lc.数组;

import java.util.Arrays;

/**
 * @description:
 * @author: qian
 * @createDate: 2021/10/15
 */
public class 左奇右偶 {

    public static int[] t(int[] arr) {

        int l = 0;
        int r = arr.length - 1;

        while (l < r) {
            while (arr[l] % 2 == 1 && l < r)
                l++;

            while (arr[r] % 2 == 0 && l < r)
                r--;

            int t = arr[l];
            arr[l] = arr[r];
            arr[r] = t;

        }
        return arr;

    }


    public static void main(String[] args) {

        int arr[] = {1,2,3,4,5,6,7,8,9,10};
        t(arr);
        System.out.println(Arrays.toString(arr));
    }
}
